package com.kizuki.io;

import java.io.*;

public class TestObjectStream {

    public static void main(String[] args) throws IOException {
        SuperMan man = new SuperMan("man", 100);

        File f = new File("d:/java/learnio/TestObjectStream.txt");
        if (!f.getParentFile().exists()) {
            f.getParentFile().mkdirs();
        }
        if (!f.exists()) {
            f.createNewFile();
        }

        try(
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(f));
            ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(f));
        ) {
            objectOutputStream.writeObject(man);
            SuperMan man2 = (SuperMan)objectInputStream.readObject();
            System.out.println(man2);
        } catch (Exception e) {
            System.out.println("异常");
        }

    }
}
